Interview Questions and Answers - Order By Newest Q41. Which of the following - arrays or LinkedList allow elements to be accessed using index and how ? Data Structure
Ans. Arrays allows elements to be accessed directly using the index.
As Array elements are stored in continuous memory locations it's very easy to find the memory address of any element using the formula as following
Memory Address of Array start or index 0 + ( Size of array element * Index ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  linkedlist Q42. Can we access elements at a particular index using LinkedList collection class ? Data Structure
Ans. Yes we can. But as the underlying structure of the collection class is double linked list, it will eventually have to traverse to the element linearlly and hence would result in bad performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q43. If a stack is implemented using an array, which end (head or tail) should represent the top ? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q44. If a stack is implemented using linkedlist, which end (head or tail) should represent the top ? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q45. Describe how a queue is usually created using sequential allocation. Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q46. What is the "multiplicative congruence" method for determining where an element belongs in a hash table ? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q47. What is the access time for ArrayList and LinkedList ? Data Structure
Ans. O(1) for ArrayList
O(n) for LinkedList Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q48. Write a method that returns maximum depth of a tree ? Algorithm
This question was recently asked at 'One Click Retail'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  tree  data structure  maximum depth of tree Asked in 1 Companies Q49. What can we do if we need to retrieve Fibonacci value at a particular index faster ? Can we use Linked List ? Data Structure
This question was recently asked at 'Canopy Tax'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  LinkedList Asked in 1 Companies Q50. How will you implement your own custom hashmap and linkedlist ? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Ans. The array index starts with 0 because program locates an element using the expression ( BaseAddress + ( Index * size of array Element ), where index is used as an offset. As the starting address is actually the address of first element, the index of first element is used as 0 and so on. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q52. Why does an array need continuous memory locations and not Linked List ? Data Structure
Ans. Array needs continuous memory location because it need to provide random access of it's elements which is not required for Linked List.
Array index acts as an offset from the base address and hence can retrieve the respective element using the expression Base Address + ( Index * Element Size ). This expression could only hold true if the elements are in continuous memory location. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Ans. Hashing is a technique to calculate the hash code for any object Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q54. Can you write code to copy one array into another ? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays vs linkedlist Q56. In an array every element is repeated twice except one, Find that element? Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q58. Find the length of the non repeated numbers in an array. Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q59. Write a program to insert a value after a specific value in an array. Data Structure
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q60. Write a Program to Find the maximum sum of the sub array ? Data Structure
This question was recently asked at 'Reddit'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Maximum subarray variant  arrays  sub array  subarray Asked in 1 Companies Ans. Work with two pointers on the linked list - a slow pointer (increments by one node) and a fast pointer (increments by two nodes). If both of these pointers meet at the same node, then there is a cycle in the linked list. Otherwise, no cycle. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  linkedlist Asked in 1 Companies Q62. Implement a Stack with 2 threads in which one thread push data and another pop data. Data Structure
This question was recently asked at 'HCL Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  stack Asked in 1 Companies This question was recently asked at 'Unisys'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q64. Write a Program to print all nodes of the data structure ? Algorithm
This question was recently asked at 'Overstock.com'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  data structure  algorithm Asked in 1 Companies This question was recently asked at 'IBM India'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  queue  stack Asked in 1 Companies This question was recently asked at 'Jefferies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies This question was recently asked at 'Compro Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. Message queues implement an asynchronous communication pattern between two or more processes/threads whereby the sending and receiving party do not need to interact with the message queue at the same time. Messages placed onto the queue are stored until the recipient retrieves them. Message queues have implicit or explicit limits on the size of data that may be transmitted in a single message and the number of messages that may remain outstanding on the queue. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  message queue Asked in 1 Companies Q69. What is the time complexity and space complexity of reversing a Linked List ? Data Structure
Ans. o(n) for time complexity
o(1) for space complexity Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q70. Write an algorithm to shift a linked list n positions. Data Structure
This question was recently asked at 'Amdocs'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies